<?php
 if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class m_news_type extends CI_Model{
	
	function __construct()
	{
		parent::__construct();
	} 
	function get_news_type_num(){
		
		return $this->db->count_all('com_news_type');
	}
	function get_news_type($num, $offset){
		$query = $this->db->get('com_news_type', $num, $offset);      
        return $query->result();   
	}
	function save_news_type($type_name,$is_top){
		return $this->db->query('insert into `'.$this->db->dbprefix('com_news_type').'` set 
				`type_name`=\''.$type_name.'\',
				`is_top`=\''.$is_top.'\',
				`version`=\'1\',
				`add_time`=\''.time().'\'
		');
	}
	function get_news_type_ById($id){
		return $this->db->query('select `type_name`,`is_top` from  `'.$this->db->dbprefix('com_news_type').'` where `id`=\''.$id.'\' ')->row_array();

	}
	function update_news_type($type_name,$is_top,$id){
	    return $this->db->query('update  `'.$this->db->dbprefix('com_news_type').'` set `type_name`=\''.$type_name.'\',is_top='.$is_top.'  where `id`=\''.$id.'\'');	
	}
	function delete_news_type($id){
		return $this->db->query('delete from `'.$this->db->dbprefix('com_news_type').'`  where  id ='.$id);	
	}
	function batch_delete_news_type($ids){
		return $this->db->query('delete from `'.$this->db->dbprefix('com_news_type').'`  where  id in('.$ids.')');	
	}
}
?>